
<%@page import="com.informet.ipd.modelo.vo.PlanOperativoVO"%>
<%@page import="com.informet.ipd.modelo.dao.PlanOperativoDao"%>
<%@page import="com.informet.ipd.struts.form.PEIForm"%><%@ page import="com.informet.ipd.modelo.dao.APermanenteDao" %>
<%@ page import="com.informet.ipd.modelo.vo.APermanenteVO" %>
<%@ page import="com.informet.ipd.struts.form.APermanenteForm" %>
<%@ page import="java.util.*" %>
<%@ page import="javax.swing.JOptionPane"%>

<%@ taglib uri="/tags/c" prefix="c"%>

<%
            StringBuffer cadenaSalida = new StringBuffer();
            List lista = null;
            String inActPer = request.getParameter("inActPer");
            String finActPer = request.getParameter("finActPer");
            String estado = request.getParameter("estado");


            PlanOperativoDao supportFacade = new PlanOperativoDao();
            PEIForm form1=new PEIForm();
            PlanOperativoVO POper=null;
            try {
            	int codActPer = Integer.parseInt(request.getParameter("codActPer"));
                int codOE = Integer.parseInt(request.getParameter("codOE"));
                int tipo= Integer.parseInt(request.getParameter("tipo"));
                String dep=session.getAttribute("dependencia").toString();
               int depen=Integer.parseInt(dep);
                POper=new PlanOperativoVO(codActPer,inActPer,finActPer,estado);
                supportFacade.spManM(tipo, POper);
                lista = supportFacade.getListPlanOperativoModificado(codOE,depen);
                form1.setListaActPer(lista);
                cadenaSalida.append("<table id='tabla1' width='99%' align='right' class='userTable'>");
                cadenaSalida.append("<tr class='even' align='center'>");
                cadenaSalida.append("<th class='textoTR' rowspan='2' style='width:1500px;text-align: left'>Actividad Estrat&eacute;gica</th>");
                cadenaSalida.append("<th class='textoTR' colspan='2'>Fecha</th>");
                cadenaSalida.append("<th class='textoTR' colspan='4'>Meta F&iacute;sica</th>");
                cadenaSalida.append("<th class='textoTR' colspan='2'>Meta Financiera</th>");

                cadenaSalida.append("<th class='textoTR' rowspan='2'>Ingresar Tarea</th>");
                cadenaSalida.append("<th class='textoTR' rowspan='2'>Estado</th>");
                cadenaSalida.append("<th class='textoTR' rowspan='2'>Editar</th>");

                cadenaSalida.append("</tr>");
                cadenaSalida.append("<tr class='even' align='center'>");

                cadenaSalida.append("<th class='textoTR'>Inicio</th>");
                cadenaSalida.append("<th class='textoTR'>T&eacute;rmino</th>");
                cadenaSalida.append("<th class='textoTR'>Descripci&oacute;n</th>");
                cadenaSalida.append("<th class='textoTR'>Cantidad</th>");
                cadenaSalida.append("<th class='textoTR'>UM</th>");
                cadenaSalida.append("<th class='textoTR'>Detalle Anual</th>");
                cadenaSalida.append("<th class='textoTR'>PPTO</th>");
                cadenaSalida.append("<th class='textoTR'>Detalle Anual</th>");
                cadenaSalida.append("</tr>");
                int flag1=0;
                int flag2=0;
                int flag3=0;
                int flag4=0;
                int i=1;
                Iterator it = lista.iterator();
                while (it.hasNext()) {
                	POper = (PlanOperativoVO) it.next();
                        int cont=0;
                        int cont2=0;
                        for(i=0;i<lista.size();i++){
                                    PlanOperativoVO planoperativo=(PlanOperativoVO)lista.get(i);
                                    if(planoperativo.getNUM_CODACTPER_PK()==POper.getNUM_CODACTPER_PK()){
                                        cont=cont+1;
                                        if(planoperativo.getNUM_CODMETAAPER_PK()==(POper.getNUM_CODMETAAPER_PK())){
                                        cont2=cont2+1;
                                    }
                                    }
                                    }
                    cadenaSalida.append("<tr align='center'> ");
                     if(flag1!=POper.getNUM_CODACTPER_PK()){
                                    cadenaSalida.append("<td style='width:1500px;text-align: left' align='center' rowspan='" +cont+"'> "+ POper.getTX_DESCACTPER() + "</td>");
                                    flag1=POper.getNUM_CODACTPER_PK();
                                }

                    if(flag4!=(POper.getNUM_CODACTPER_PK())){
                    cadenaSalida.append("<td width='8%' align='center' rowspan='" +cont+"'>" +POper.getDT_INIACTPER() + "</td>");
                                    cadenaSalida.append("<td width='8%' align='center' rowspan='" +cont+"'>" +POper.getDT_TERACTPER() + "</td>");
                    flag4=POper.getNUM_CODACTPER_PK();
                                }








                    if(flag2!=(POper.getNUM_CODMETAAPER_PK())){
                    cadenaSalida.append("<td width='8%' align='center'rowspan='" +cont2+"'>" + POper.getTX_UMACTPER() + "</td>");
                    cadenaSalida.append("<td width='8%' align='center' rowspan='" +cont2+"'>" + POper.getNUM_CANTACTPER() + "</td>");
                    cadenaSalida.append("<td width='8%' align='center' rowspan='" +cont2+"'>" + POper.getTX_TIPOACTPER() + "</td>");
                    cadenaSalida.append("<td width='5%' align='center' rowspan='" +cont2+"'>");
                    if(POper.getStringActSusp().equals("Suspendido")){
                    cadenaSalida.append("<img style='cursor:pointer' title='Meta' alt='Meta' border=0  src='images/file_preview.png' onclick=\"error();\">");
                    }
                    else{
                        if(POper.getDT_INIACTPER().equals("(vacio)")||POper.getDT_TERACTPER().equals("(vacio)")){
                    cadenaSalida.append("<img style='cursor:pointer' title='Meta' alt='Meta' border=0  src='images/file_preview.png' onclick=\"error2();\">");
                    }
                    else{
                    cadenaSalida.append("<img style='cursor:pointer' title='Meta' alt='Meta' border=0  src='images/file_preview.png' onclick=\"MetaFisica('"+POper.getNUM_CODACTPER_PK()+"','"+POper.getNUM_CODMETAAPER_PK()+"','"+POper.getTX_UMACTPER()+"','"+POper.getNUM_CANTACTPER()+"','"+POper.getTX_TIPOACTPER()+"','"+POper.getTX_DESCACTPER()+"','"+POper.getDT_INIACTPER().substring(3, 5)+"','"+POper.getDT_TERACTPER().substring(3, 5)+"','"+POper.getCodObj()+"','"+POper.getCodObjEsp()+"','"+POper.getDescObj()+"','"+POper.getDescObjEsp()+"');\">");
                    }





                    }
                    cadenaSalida.append("</td>");
                                    flag2=POper.getNUM_CODMETAAPER_PK();
                                }





                    if(flag3!=(POper.getNUM_CODACTPER_PK())){
                                    cadenaSalida.append("<td width='8%' align='center' rowspan='" +cont+"'>" + POper.getTOTAL() + "</td>");
                                    cadenaSalida.append("<td width='5%' align='center' rowspan='" +cont+"'>");
                    if(POper.getStringActSusp().equals("Suspendido")){
                    cadenaSalida.append("<img style='cursor:pointer' title='Meta' alt='Meta' border=0  src='images/file_preview.png' onclick=\"error();\">");
                    }
                    else{
                   if(POper.getDT_INIACTPER().equals("(vacio)")||POper.getDT_TERACTPER().equals("(vacio)")){
                    cadenaSalida.append("<img style='cursor:pointer' title='Meta' alt='Meta' border=0  src='images/file_preview.png' onclick=\"error2();\">");
                    }
                    else{
                    cadenaSalida.append("<img style='cursor:pointer' title='Meta' alt='Meta' border=0  src='images/file_preview.png' onclick=\"MetaFinanciera('"+POper.getNUM_CODACTPER_PK()+"','"+POper.getTX_DESCACTPER()+"','"+POper.getTOTAL()+"','"+POper.getDT_INIACTPER().substring(3, 5)+"','"+POper.getDT_TERACTPER().substring(3, 5)+"','"+POper.getCodObj()+"','"+POper.getCodObjEsp()+"','"+POper.getDescObj()+"','"+POper.getDescObjEsp()+"');\">");
                    }

                    }
                    cadenaSalida.append("</td>");
                    
                                    cadenaSalida.append("<td width='5%' align='center' rowspan='" +cont+"'>");


                                    //por ver
                    if(POper.getStringActSusp().equals("Suspendido")){
                        cadenaSalida.append("<img style='cursor:pointer' title='Meta' alt='Meta' border=0  src='images/file_preview.png' onclick=\"error();\">");
                    }else{
                    if(POper.getDT_INIACTPER().equals("(vacio)")||POper.getDT_TERACTPER().equals("(vacio)")){
                    cadenaSalida.append("<img style='cursor:pointer' title='Meta' alt='Meta' border=0  src='images/file_preview.png' onclick=\"error2();\">");
                    }
                    else{
                    cadenaSalida.append("<img style='cursor:pointer' title='Meta' alt='Meta' border=0  src='images/file_preview.png' onclick=\"tareaActividad('"+POper.getNUM_CODACTPER_PK()+"','"+POper.getTX_DESCACTPER()+"','"+POper.getTOTAL()+"','"+POper.getDT_INIACTPER()+"','"+POper.getDT_TERACTPER()+"','"+POper.getCodObj()+"','"+POper.getCodObjEsp()+"','"+POper.getDescObj()+"','"+POper.getDescObjEsp()+"');\">");
                    }



                    }
                    cadenaSalida.append("</td>");
		    cadenaSalida.append("<td width='8%' align='center' rowspan='" +cont+"'>" + POper.getStringActSusp() + "</td>");
                    cadenaSalida.append("<td width='5%' align='center' rowspan='" +cont+"'>");
                    cadenaSalida.append("<img style='cursor:pointer' title='Editar' alt='Editar' border=0  src='images/b_edit.png' onclick=\"editarT('"+POper.getNUM_CODACTPER_PK()+"','"+POper.getDT_INIACTPER()+"','"+POper.getDT_TERACTPER()+"','"+POper.getNUM_ACTSUSPENSION()+"');posicioninicial();\">");
                    cadenaSalida.append("</td>");
                                    flag3=POper.getNUM_CODACTPER_PK();
                                }




                    


                    //}
                    cadenaSalida.append("</tr>");
                }
            } catch (Exception e) {
               cadenaSalida.append("error : "+e.toString());
            }
            out.print(cadenaSalida);
%>